package com.sskj.fabi.presenter;

import com.lzy.okgo.model.Response;
import com.lzy.okrx2.adapter.FlowableBody;
import com.sskj.common.base.HttpData;
import com.sskj.common.util.ToastUtil;
import com.sskj.fabi.bean.FBPrice;
import com.sskj.fabi.bean.FabiListBean;
import com.sskj.fabi.bean.OrderDetailBean;
import com.sskj.fabi.bean.RecordTradeBean;
import com.sskj.fabi.http.HttpConfig;
import com.sskj.fabi.ui.fragment.RecordFragment;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.http.JsonCallBack;
import com.sskj.lib.http.JsonConverter;

import java.util.List;

import io.reactivex.Flowable;

public class RecordPresenter extends BasePresenter<RecordFragment> {

    /**
     * 获取交易记录
     */
    public void getRecordList(int p, int page) {
        httpService.getRecordList(p, page)
                .execute(new JsonCallBack<HttpData<PageBean<RecordTradeBean>>>(this) {
                    @Override
                    public void onSuccess(Response<HttpData<PageBean<RecordTradeBean>>> response) {
                        HttpData<PageBean<RecordTradeBean>> httpData = response.body();
                        if (httpData.getStatus() == HttpConfig.OK) {
                            if (httpData.getData().getList().size() == 0 && p != 1) {
                                ToastUtil.showShort("亲，已经到底了");
                            } else {
                                mView.setData(httpData.getData());
                            }
                        } else {
                            ToastUtil.showShort(httpData.getMsg());
                        }
                    }

                    @Override
                    public void onError(Response<HttpData<PageBean<RecordTradeBean>>> response) {
                        super.onError(response);
                    }
                });
    }
}
